/* 
 * File:   main.h
 * Author: mrossetti
 *
 * Created on 22 giugno 2011, 15.50
 */

#ifndef MAIN_H
#define	MAIN_H

#include "SDL/SDL.h"
#include "CEvent.h"
#include "CSurface.h"

class Main : public CEvent {
    private:
        bool Running;
        bool GameEnded;
        bool isFree;
        bool EndDisplayed;
        SDL_Surface* Surf_Display;
        SDL_Surface* Surf_Grid;
        SDL_Surface* Surf_X;
        SDL_Surface* Surf_O;
        SDL_Surface* Surf_text;
        SDL_Surface* Surf_text_winner;

        int Grid[9];
        char* Players[2];
        char* Winners[2];
        
        enum{
            GRID_TYPE_NONE = 0,
            GRID_TYPE_X,
            GRID_TYPE_O
        };
        int CurrentPlayer;
        
    public:
        Main();
        int OnExecute();

    public:
        bool OnInit();
        void OnEvent(SDL_Event* Event);
        void OnExit();
        void OnLButtonDown(int mX, int mY);
        void OnLoop();
        void OnRender();
        void OnCleanup();
        
        void Reset();
        void SetCell(int ID, int Type);
        void ChangePlayer();
        void ScanGrid4Winner();
        void ScanGrid4FreeSpace();
        void DisplayWinner();
        int minimalAI();
};

#endif	/* MAIN_H */

